package com.wind.cloud.common.lock;

import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class LockConfig {

    @Bean
    @ConditionalOnClass(name = "org.springframework.data.redis.core.StringRedisTemplate")
    @ConditionalOnBean(type = "org.springframework.data.redis.core.StringRedisTemplate")
    public SimpleRedisLock simpleRedisLock() {
        return new SimpleRedisLock();
    }

    @Bean
    @ConditionalOnMissingBean(ILock.class)
    public SimpleDbLock simpleDbLock() {
        return new SimpleDbLock();
    }

}
